#include "stdinc.h"
#include "DCPlusPlus.h"

#include "ClientProfileManager.h"
#include "SimpleXML.h"
// pothead added for stringdefs svn61
#include "ResourceManager.h"
// pothead end

Isp::Ptr ClientProfileManager::unknown = new Isp("Unknown", 0, false);

void ClientProfileManager::saveClientProfiles() {
	try {
		SimpleXML xml;
		xml.addTag("Profiles");
		xml.stepIn();

		xml.addTag("ClientProfilesV2");
		xml.stepIn();
		for(ClientProfile::Iter l = clientProfiles.begin(); l != clientProfiles.end(); ++l) {
			xml.addTag("ClientProfile");
			xml.stepIn();
			xml.addTag("Name", l->getName());
			xml.addTag("Version", l->getVersion());
			xml.addTag("Tag", l->getTag());
			xml.addTag("ExtendedTag", l->getExtendedTag());
			xml.addTag("Lock", l->getLock());
			xml.addTag("Pk", l->getPk());
			xml.addTag("Supports", l->getSupports());
			xml.addTag("TestSUR", l->getTestSUR());
			xml.addTag("UserConCom", l->getUserConCom());
			xml.addTag("Status", l->getStatus());
			xml.addTag("CheatingDescription", l->getCheatingDescription());
			xml.addTag("RawToSend", Util::toString(l->getRawToSend()));
			//xml.addTag("TagVersion", Util::toString(l->getTagVersion()));
			xml.addTag("UseExtraVersion", Util::toString(l->getUseExtraVersion()));
			xml.addTag("CheckMismatch", Util::toString(l->getCheckMismatch()));
			xml.addTag("Connection", l->getConnection());
			xml.addTag("Comment", l->getComment());
			xml.addTag("Recheck", l->getRecheck());
			xml.addTag("SkipExtended", l->getSkipExtended());
			xml.addTag("SkipExtended2", l->getSkipExtended2());
			xml.stepOut();
		}
		xml.stepOut();

		xml.addTag("Params");
		xml.stepIn();
		for(StringMap::iterator m = params.begin(); m != params.end(); ++m) {
			xml.addTag("Param");
			xml.addChildAttrib("Name", m->first);
			xml.addChildAttrib("RegExp", m->second);
		}
		xml.stepOut();

		xml.addTag("FileListDetector");
		xml.stepIn();
		for(FileListDetectorProfile::Iter l = fileListDetector.begin(); l != fileListDetector.end(); ++l) {
			xml.addTag("FileListDetectorProfile");
			xml.stepIn();
			xml.addTag("Name", l->getName());
			xml.addTag("CheatingDescription", l->getCheatingDescription());
			xml.addTag("RawToSend", Util::toString(l->getRawToSend()));
			//Sulan start svn120
			xml.addTag("Client", l->getClient());
			//End
			xml.stepOut();
		}
		xml.stepOut();
		
		//Sulan start svn51
		xml.addTag("ProfileInfo");
		xml.stepIn();
			xml.addTag("ProfileVersion", ClientProfileManager::getInstance()->getProfileVersion());
			xml.addTag("ProfileMessage", ClientProfileManager::getInstance()->getProfileMessage());
			xml.addTag("ProfileUrl", ClientProfileManager::getInstance()->getProfileUrl());
		xml.stepOut();
		//End

		xml.stepOut();

		string fname = Util::getAppPath() + "XML\\Profiles.xml";

		File f(fname + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
		f.write(SimpleXML::w1252Header);
		f.write(xml.toXML());
		f.close();
		File::deleteFile(fname);
		File::renameFile(fname + ".tmp", fname);

	} catch(const Exception& e) {
		dcdebug("HubManager::saveClientProfiles: %s\n", e.getError().c_str());
	}
}

void ClientProfileManager::saveFakeShares() {
	try {
		SimpleXML xml;
		
		xml.addTag("Fakes");
		xml.stepIn();

		xml.addTag("FakeShares");
		xml.stepIn();
		for(FakeShares::Iter l = fakeShares.begin(); l != fakeShares.end(); ++l) {
			xml.addTag("FakeShares");
			xml.addChildAttrib("Value", l->getValue());
			xml.addChildAttrib("Type", l->getType());
		}
		xml.stepOut();

		xml.stepOut();

		string fname = Util::getAppPath() + "XML\\Fakes.xml";

		File f(fname + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
		f.write(SimpleXML::w1252Header);
		f.write(xml.toXML());
		f.close();
		File::deleteFile(fname);
		File::renameFile(fname + ".tmp", fname);

	} catch(const Exception& e) {
		dcdebug("HubManager::saveFakeShares: %s\n", e.getError().c_str());
	}
}

void ClientProfileManager::loadClientProfiles(SimpleXML* aXml) {
	StringList sl, fl;

	aXml->resetCurrentChild();
	if(aXml->findChild("ClientProfilesV2")) {
		aXml->stepIn();
		while(aXml->findChild("ClientProfile")) {
			aXml->stepIn();
			if(aXml->findChild("Name"))					{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Version"))				{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Tag"))					{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("ExtendedTag"))			{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Lock"))					{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Pk"))					{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Supports"))				{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("TestSUR"))				{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("UserConCom"))			{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Status"))				{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("CheatingDescription"))	{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("RawToSend"))			{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			//if(aXml->findChild("TagVersion"))			{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("UseExtraVersion"))		{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("CheckMismatch"))		{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Connection"))			{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Comment"))				{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Recheck"))				{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("SkipExtended"))			{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("SkipExtended2"))			{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			
			addClientProfile(sl[0], sl[1], sl[2], sl[3], sl[4], sl[5], sl[6], sl[7], sl[8], sl[9], sl[10], Util::toInt(sl[11]), 
				Util::toBool(sl[12]), Util::toBool(sl[13]), sl[14], sl[15], Util::toBool(sl[16]), Util::toBool(sl[17]), Util::toBool(sl[18]));
			sl.clear();
			aXml->stepOut();
		}
		aXml->stepOut();
	}
	aXml->resetCurrentChild();
	if(aXml->findChild("Params")) {
		aXml->stepIn();
		while(aXml->findChild("Param")) {
			params[aXml->getChildAttrib("Name")] = aXml->getChildAttrib("RegExp");
		}
		aXml->stepOut();
	}

	aXml->resetCurrentChild();
	if(aXml->findChild("FileListDetector")) {
		aXml->stepIn();
		while(aXml->findChild("FileListDetectorProfile")) {
			aXml->stepIn();
			if(aXml->findChild("Name"))					{ fl.push_back(aXml->getChildData()); }	else { fl.push_back(Util::emptyString); }	
			if(aXml->findChild("CheatingDescription"))	{ fl.push_back(aXml->getChildData()); }	else { fl.push_back(Util::emptyString); }
			if(aXml->findChild("RawToSend"))			{ fl.push_back(aXml->getChildData()); }	else { fl.push_back(Util::emptyString); }
			if(aXml->findChild("Client"))				{ fl.push_back(aXml->getChildData()); }	else { fl.push_back(Util::emptyString); }	
			
			addFileListDetector(fl[0], fl[1],Util::toInt(fl[2]), fl[3]);
			fl.clear();
			aXml->stepOut();
		}
		aXml->stepOut();
	}

	//Sulan start svn51
	aXml->resetCurrentChild();
	if(aXml->findChild("ProfileInfo")) {
		aXml->stepIn();
		if(aXml->findChild("ProfileVersion"))	{ ClientProfileManager::getInstance()->setProfileVersion(aXml->getChildData()); }
		if(aXml->findChild("ProfileMessage"))	{ ClientProfileManager::getInstance()->setProfileMessage(aXml->getChildData()); }
		if(aXml->findChild("ProfileUrl"))		{ ClientProfileManager::getInstance()->setProfileUrl(aXml->getChildData()); }
		aXml->stepOut();
	}
	//End
}

void ClientProfileManager::loadClientProfiles() {
	try {
		SimpleXML xml;
		xml.fromXML(File(Util::getAppPath() + "XML\\Profiles.xml", File::READ, File::OPEN).read());
		
		if(xml.findChild("Profiles")) {
			xml.stepIn();
			loadClientProfiles(&xml);
			xml.stepOut();
		}
	} catch(const Exception& e) {
		dcdebug("HubManager::loadClientProfiles: %s\n", e.getError().c_str());
	}
}

void ClientProfileManager::loadFakeShares() {
	try {
		SimpleXML xml;
		xml.fromXML(File(Util::getAppPath() + "XML\\Fakes.xml", File::READ, File::OPEN).read());
		
		if(xml.findChild("Fakes")) {
			xml.stepIn();
			loadFakeShares(&xml);
			xml.stepOut();
		}
	} catch(const Exception& e) {
		dcdebug("HubManager::loadFakeShares: %s\n", e.getError().c_str());
	}
}

void ClientProfileManager::loadFakeShares(SimpleXML* aXml) {
	aXml->resetCurrentChild();
	if(aXml->findChild("FakeShares")) {
		aXml->stepIn();
		while(aXml->findChild("FakeShares")) {
			fakeShares.push_back(
				FakeShares(
				aXml->getChildAttrib("Value"),
				aXml->getChildAttrib("Type")
				)
			);
		}
		aXml->stepOut();
	}
}

void ClientProfileManager::loadISPs() {
	try {
		SimpleXML xml;
		xml.fromXML(File(Util::getAppPath() + "XML\\ISPs.xml", File::READ, File::OPEN).read());
		if(xml.findChild("ISP")) {
			xml.stepIn();
			loadISPs(&xml);
			xml.stepOut();
		}
	} catch(const Exception& e) {
		dcdebug("HubManager::loadISPs: %s\n", e.getError().c_str());
	}
}

void ClientProfileManager::loadISPs(SimpleXML* aXml) {
	if(BOOLSETTING(ISP_CHECKING)) {
		bool checkConflicts = BOOLSETTING(CHECK_CONFLICTS);
		aXml->resetCurrentChild();
		string msg;
		bool conflict;
		bool write = false;
		while(aXml->findChild("ISPs")) {
			conflict = false;
			string range(aXml->getChildAttrib("Range"));
			string isp(aXml->getChildAttrib("ISP"));
			bool bad(aXml->getBoolChildAttrib("Bad"));
			u_int32_t low = Util::getLowerRange(range);
			u_int32_t high = Util::getUpperRange(range);
			if(checkConflicts) {
				for(Isp::Iter j = ispList.begin(); j != ispList.end(); ++j) {
					if( (j->second->getLower() <= low && j->first >= low) || (j->second->getLower() <= high && j->first >= high) ) {
						msg += STRING(ISPDLG_RANGE) + ": \r\n" + range + " " + STRING(ISP) + ": " + isp + "\r\n" + STRING(ISPDLG_CONFLICT) + " \r\n" + Util::toIP(j->second->getLower()) + '-' + Util::toIP(j->first) + " " + STRING(ISP) + ": " + j->second->getIsp() + "\r\n" + STRING(NOT_ADDED_ISP_LIST) + "\r\n\r\n";
						write = conflict = true;
					}
				}
			}
			if(!conflict) {
				insertISP(Util::getUpperRange(range), Util::getLowerRange(range), isp, bad);
			}
		}
		if(write) {
			string fname = Util::getAppPath() + "conflicts.txt";

			File f(fname + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
			f.write(msg);
			f.close();
			File::deleteFile(fname);
			File::renameFile(fname + ".tmp", fname);
		}
	}
}

void ClientProfileManager::saveISPs() {
	try {
		if(!ispList.empty()) {
			SimpleXML xml;
		
			xml.addTag("ISP");
			xml.stepIn();

			for(Isp::Iter l = ispList.begin(); l != ispList.end(); ++l) {
				xml.addTag("ISPs");
				xml.addChildAttrib("Range", Util::toIP(l->second->getLower()) + '-' + Util::toIP(l->first));
				xml.addChildAttrib("ISP", l->second->getIsp());
				xml.addChildAttrib("Bad", l->second->getBad());
			}
			xml.stepOut();

			string fname = Util::getAppPath() + "XML\\ISPs.xml";

			File f(fname + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
			f.write(SimpleXML::w1252Header);
			f.write(xml.toXML());
			f.close();
			File::deleteFile(fname);
			File::renameFile(fname + ".tmp", fname);
		}
	} catch(const Exception& e) {
		dcdebug("HubManager::saveISPs: %s\n", e.getError().c_str());
	}
}

Isp::Ptr& ClientProfileManager::getISP(const string& IP) {
	string::size_type a = IP.find('.');
	string::size_type b = IP.find('.', a+1);
	string::size_type c = IP.find('.', b+2);

	u_int32_t ipnum = (Util::toUInt32(IP.c_str()) << 24) | 
		(Util::toUInt32(IP.c_str() + a + 1) << 16) | 
		(Util::toUInt32(IP.c_str() + b + 1) << 8) | 
		(Util::toUInt32(IP.c_str() + c + 1) );
	{
		Lock l(ics);
		Isp::Iter j = ispList.lower_bound(ipnum);
		if(j != ispList.end()) {
			if(j->second->getLower() <= ipnum) {
				return j->second;
			}
		}
	}
	return unknown;
}

bool ClientProfileManager::isBadRange(u_int32_t aKey) {
	Lock l(ics);
	Isp::Iter j = ispList.find(aKey);
	if(j != ispList.end()) {
		return j->second->getBad();
	}
	return false;
}

// pothead starts svn196 (sulan code)
void ClientProfileManager::saveMyinfoProfiles() {
	try {
		SimpleXML xml;
		xml.addTag("Myinfo");
		xml.stepIn();

		xml.addTag("MyinfoProfiles");
		xml.stepIn();
		for(MyinfoProfile::Iter l = myinfoProfiles.begin(); l != myinfoProfiles.end(); ++l) {
			xml.addTag("MyinfoProfile");
			xml.stepIn();
			xml.addTag("Name", l->getName());
			xml.addTag("Version", l->getVersion());
			xml.addTag("Tag", l->getTag());
			xml.addTag("ExtendedTag", l->getExtendedTag());
			xml.addTag("Nick", l->getNick());
			xml.addTag("Shared", l->getShared());
			xml.addTag("Email", l->getEmail());
			xml.addTag("Status", l->getStatus());
			xml.addTag("CheatingDescription", l->getCheatingDescription());
			xml.addTag("RawToSend", Util::toString(l->getRawToSend()));
			xml.addTag("UseExtraVersion", Util::toString(l->getUseExtraVersion()));
			xml.addTag("Connection", l->getConnection());
			xml.addTag("Comment", l->getComment());
			xml.stepOut();
		}
		xml.stepOut();

		xml.addTag("ProfileInfo");
		xml.stepIn();
			xml.addTag("ProfileVersion", ClientProfileManager::getInstance()->getMyinfoProfileVersion());
			xml.addTag("ProfileMessage", ClientProfileManager::getInstance()->getMyinfoProfileMessage());
			xml.addTag("ProfileUrl", ClientProfileManager::getInstance()->getMyinfoProfileUrl());
		xml.stepOut();

		xml.stepOut();

		string fname = Util::getAppPath() + "XML\\MyinfoProfiles.xml";

		File f(fname + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
		f.write(SimpleXML::w1252Header);
		f.write(xml.toXML());
		f.close();
		File::deleteFile(fname);
		File::renameFile(fname + ".tmp", fname);

	} catch(const Exception& e) {
		dcdebug("HubManager::saveMyinfoProfiles: %s\n", e.getError().c_str());
	}
}

void ClientProfileManager::loadMyinfoProfiles() {
	try {
		SimpleXML xml;
		xml.fromXML(File(Util::getAppPath() + "XML\\MyinfoProfiles.xml", File::READ, File::OPEN).read());
	/**/	
		if(xml.findChild("Myinfo")) {
			xml.stepIn();
			loadMyinfoProfiles(&xml);
			xml.stepOut();
		}
	} catch(const Exception& e) {
		dcdebug("HubManager::loadMyinfoProfiles: %s\n", e.getError().c_str());
	}
}

void ClientProfileManager::loadMyinfoProfiles(SimpleXML* aXml) {
	StringList sl;
	aXml->resetCurrentChild();
	if(aXml->findChild("MyinfoProfiles")) {
		aXml->stepIn();
		while(aXml->findChild("MyinfoProfile")) {
			aXml->stepIn();
			if(aXml->findChild("Name"))					{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Version"))				{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Tag"))					{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("ExtendedTag"))			{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Nick"))					{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Shared"))				{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Email"))				{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Status"))				{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("CheatingDescription"))	{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("RawToSend"))			{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("UseExtraVersion"))		{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Connection"))			{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
			if(aXml->findChild("Comment"))				{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }		
			addMyinfoProfile(sl[0], sl[1], sl[2], sl[3], sl[4], sl[5], sl[6], sl[7], sl[8], Util::toInt(sl[9]), Util::toBool(sl[10]), sl[11], sl[12]);
			sl.clear();
			aXml->stepOut();
		}
		aXml->stepOut();
	} 
	aXml->resetCurrentChild();
	if(aXml->findChild("ProfileInfo")) {
		aXml->stepIn();
		if(aXml->findChild("ProfileVersion"))	{ ClientProfileManager::getInstance()->setMyinfoProfileVersion(aXml->getChildData()); }
		if(aXml->findChild("ProfileMessage"))	{ ClientProfileManager::getInstance()->setMyinfoProfileMessage(aXml->getChildData()); }
		if(aXml->findChild("ProfileUrl"))		{ ClientProfileManager::getInstance()->setMyinfoProfileUrl(aXml->getChildData()); }
		aXml->stepOut();
	}
}
// pothead ends
// pothead starts
void ClientProfileManager::saveRawProfiles() {
	try {
		SimpleXML xml;
		xml.addTag("Raws");
		xml.stepIn();
		xml.addTag("Rawstring1", getRawstring1());
		xml.addTag("Rawstring2", getRawstring2());
		xml.addTag("Rawstring3", getRawstring3());
		xml.addTag("Rawstring4", getRawstring4());
		xml.addTag("Rawstring5", getRawstring5());
		xml.addTag("Rawstring6", getRawstring6());
		xml.addTag("Rawstring7", getRawstring7());
		xml.addTag("Rawstring8", getRawstring8());
		xml.addTag("Rawstring9", getRawstring9());
		xml.addTag("Rawstring10", getRawstring10());
		for(RawProfile::Iter l = rawProfiles.begin(); l != rawProfiles.end(); ++l) {
			
			xml.addTag("RawProfile");
			xml.stepIn();
			xml.addTag("Name", l->getName());
			xml.addTag("Raw1", l->getRaw1());
			xml.addTag("Raw2", l->getRaw2());
			xml.addTag("Raw3", l->getRaw3());
			xml.addTag("Raw4", l->getRaw4());
			xml.addTag("Raw5", l->getRaw5());
			xml.addTag("Raw6", l->getRaw6());
			xml.addTag("Raw7", l->getRaw7());
			xml.addTag("Raw8", l->getRaw8());
			xml.addTag("Raw9", l->getRaw9());
			xml.addTag("Raw10", l->getRaw10());
			xml.stepOut();
		}
		xml.stepOut();

		string fname = Util::getAppPath() + "XML\\RawProfiles.xml";

		File f(fname + ".tmp", File::WRITE, File::CREATE | File::TRUNCATE);
		f.write(SimpleXML::w1252Header);
		f.write(xml.toXML());
		f.close();
		File::deleteFile(fname);
		File::renameFile(fname + ".tmp", fname);

	} catch(const Exception& e) {
		dcdebug("HubManager::saveRawProfiles: %s\n", e.getError().c_str());
	}
}

void ClientProfileManager::loadRawProfiles() {
	try {
		SimpleXML xml;
		xml.fromXML(File(Util::getAppPath() + "XML\\RawProfiles.xml", File::READ, File::OPEN).read());
	/**/	
		if(xml.findChild("Raws")) {
			xml.stepIn();
			loadRawProfiles(&xml);
			xml.stepOut();
		}
	} catch(const Exception& e) {
		dcdebug("HubManager::loadRawProfiles: %s\n", e.getError().c_str());
	}
}

void ClientProfileManager::loadRawProfiles(SimpleXML* aXml) {
	StringList sl;
	aXml->resetCurrentChild();
	if(aXml->findChild("Rawstring1"))setRawstring1(aXml->getChildData());
	if(aXml->findChild("Rawstring2"))setRawstring2(aXml->getChildData());
	if(aXml->findChild("Rawstring3"))setRawstring3(aXml->getChildData());
	if(aXml->findChild("Rawstring4"))setRawstring4(aXml->getChildData());
	if(aXml->findChild("Rawstring5"))setRawstring5(aXml->getChildData());
	if(aXml->findChild("Rawstring6"))setRawstring6(aXml->getChildData());
	if(aXml->findChild("Rawstring7"))setRawstring7(aXml->getChildData());
	if(aXml->findChild("Rawstring8"))setRawstring8(aXml->getChildData());
	if(aXml->findChild("Rawstring9"))setRawstring9(aXml->getChildData());
	if(aXml->findChild("Rawstring10"))setRawstring10(aXml->getChildData());
	while(aXml->findChild("RawProfile")) {
		aXml->stepIn();
		if(aXml->findChild("Name"))		{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
		if(aXml->findChild("Raw1"))		{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
		if(aXml->findChild("Raw2"))		{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
		if(aXml->findChild("Raw3"))		{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
		if(aXml->findChild("Raw4"))		{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
		if(aXml->findChild("Raw5"))		{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
		if(aXml->findChild("Raw6"))		{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
		if(aXml->findChild("Raw7"))		{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
		if(aXml->findChild("Raw8"))		{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
		if(aXml->findChild("Raw9"))		{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
		if(aXml->findChild("Raw10"))	{ sl.push_back(aXml->getChildData()); }	else { sl.push_back(Util::emptyString); }
		addRawProfile(sl);
		sl.clear();
		aXml->stepOut();
	} 
}
// pothead ends
/**
 * @file
 * $Id: ClientProfileManager.cpp 331 2005-09-02 11:13:58Z sulan $
 */